/**
 */
package org.mro.grib.model.files.secondEdition.products.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.mro.grib.model.files.secondEdition.products.ProductDefinitionTemplate443;
import org.mro.grib.model.files.secondEdition.products.ProductsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Product Definition Template443</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate443Impl#getAtmosphericChemicalConstituentType <em>Atmospheric Chemical Constituent Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProductDefinitionTemplate443Impl extends ProductDefinitionTemplate412Impl implements ProductDefinitionTemplate443 {
	/**
	 * The default value of the '{@link #getAtmosphericChemicalConstituentType() <em>Atmospheric Chemical Constituent Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAtmosphericChemicalConstituentType()
	 * @generated
	 * @ordered
	 */
	protected static final short ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getAtmosphericChemicalConstituentType() <em>Atmospheric Chemical Constituent Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAtmosphericChemicalConstituentType()
	 * @generated
	 * @ordered
	 */
	protected short atmosphericChemicalConstituentType = ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProductDefinitionTemplate443Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ProductsPackage.Literals.PRODUCT_DEFINITION_TEMPLATE443;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getAtmosphericChemicalConstituentType() {
		return atmosphericChemicalConstituentType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAtmosphericChemicalConstituentType(short newAtmosphericChemicalConstituentType) {
		short oldAtmosphericChemicalConstituentType = atmosphericChemicalConstituentType;
		atmosphericChemicalConstituentType = newAtmosphericChemicalConstituentType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE443__ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE, oldAtmosphericChemicalConstituentType, atmosphericChemicalConstituentType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE443__ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE:
				return getAtmosphericChemicalConstituentType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE443__ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE:
				setAtmosphericChemicalConstituentType((Short)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE443__ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE:
				setAtmosphericChemicalConstituentType(ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE443__ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE:
				return atmosphericChemicalConstituentType != ATMOSPHERIC_CHEMICAL_CONSTITUENT_TYPE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (atmosphericChemicalConstituentType: "); //$NON-NLS-1$
		result.append(atmosphericChemicalConstituentType);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate412Impl#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		parameterCategory = buffer.get();
		parameterNumber = buffer.get();
		atmosphericChemicalConstituentType = buffer.getShort();
		typeOfGeneratingProcess = buffer.get();
		backgroundGeneratingProcess = buffer.get();
		analysisOrForecastGeneratingProcess = buffer.get();
		hoursOfObservationalDataCutOff = buffer.getShort();
		minutesOfObservationalDataCutOff = buffer.get();
		indicatorOfUnitOfTimeRange = buffer.get();
		forecastTime = buffer.getInt();
		typeOfFirstFixedSurface = buffer.get();
		scaleFactorOfFirstFixedSurface = buffer.get();
		scaledValueOfFirstFixedSurface = buffer.getInt();
		typeOfSecondFixedSurface = buffer.get();
		scaleFactorOfSecondFixedSurface = buffer.get();
		scaledValueOfSecondFixedSurface = buffer.getInt();
		derivedForecast = buffer.get();
		numberOfForecastsInEnsemble = buffer.get();
		year = buffer.getShort();
		month = buffer.get();
		day = buffer.get();
		hour = buffer.get();
		minute = buffer.get();
		second = buffer.get();
		numberOfTimeRangeSpecifications = buffer.get();
		totalNumberOfDataValuesMissing = buffer.getInt();
		outermostStatisticalProcess = buffer.get();
		outermostTypeOfTimeIncrement = buffer.get();
		outermostIndicatorOfUnitOfTimeStatisticalProcess = buffer.get();
		outermostLengthOfTheTimeRange = buffer.getInt();
		outermostIndicatorOfUnitOfTimeSuccessiveFields = buffer.get();
		outermostTimeIncrementBetweenSuccessiveFields = buffer.getInt();
		if (numberOfTimeRangeSpecifications > 1) {
			for (int i = 0; i < numberOfTimeRangeSpecifications; i++) {
				additionalStatisticalProcess.add(Byte.valueOf(buffer.get()));
				additionalTypeOfTimeIncrement.add(Byte.valueOf(buffer.get()));
				additionalIndicatorOfUnitOfTimeStatisticalProcess.add(Byte.valueOf(buffer.get()));
				additionalLengthOfTheTimeRange.add(Integer.valueOf(buffer.getInt()));
				additionalIndicatorOfUnitOfTimeSuccessiveFields.add(Byte.valueOf(buffer.get()));
				additionalTimeIncrementBetweenSuccessiveFields.add(Integer.valueOf(buffer.getInt()));
			}
		}
	}
	
} //ProductDefinitionTemplate443Impl
